package com.hjj.AppIO;

import java.io.FileInputStream;
import java.io.IOException;

/**
 * 1、方向(参照物内存)【进入内存为输入：input】【内存到其他地方为输出：output】
 * 2、单位【字节(二进制)input, output】【字符(中文) reader, writer】
 * 3、功能【连接】【过滤】
 * java.io为IO流操作的包
 */

public class MyApp1 {
    public static void main(String[] args) {
        String path = "F:\\IO\\a.txt";

        String temp = "";

        byte[] bytes = new byte[10];

        try {
            FileInputStream fileInputStream = new FileInputStream(path);

            // byte[] b：字节缓存
            // int off：
            // int len：
            // return：返回的是目前总数据量，如果没有则为-1
            /*int read = fileInputStream.read(bytes, 0, bytes.length);
            temp = new String(bytes, 0 , read);*/

            StringBuffer stringBuffer = new StringBuffer();

            int read = 0;
            while ((read = fileInputStream.read(bytes, 0, bytes.length)) != -1){
                stringBuffer.append(new String(bytes, 0, read));
            }

            temp = stringBuffer.toString();

            // 关闭文件输入流
            fileInputStream.close();
        } catch (IOException e) {
            e.printStackTrace();
        }


        System.out.println(temp);



    }
}
